<?php

if(defined("_PARA_PAGER"))
    return;
define("_PARA_PAGER", 1);

require_once "HTMLable.php";

class Pager extends HTMLable {

    public $totalcount;
    public $current_page;
    public $page_size;
    public $url;
    public $page_count;

    public $css_baseclass;

    public function Pager( $totalcount, $current_page, $page_size, $link_to ) {
        $this->totalcount   = $totalcount;
        $this->current_page = $current_page;
        $this->page_size    = $page_size;
        $this->url          = $link_to;

        $this->page_count   = ceil( $totalcount / $page_size );
    }


    public function htmlize( $options ) {
        $cssclass= $this->css_baseclass;
        echo "<div class='$cssclass'>";
        for( $i = 1; $i <= $this->page_count; $i++ ) {
            $url     = $this->url . "&page=$i";
            if($i == $this->current_page)
                echo "<span class='curpage'>$i</span>";
            else
                echo "<span class='page'><a href='$url'>$i</a></span>";
        }
        echo "</div>\n";
    }

}

?>